import Vue from "vue";
import VueRouter from "vue-router";
// import store from "@/store";
// import HomeView from "../views/HomeView.vue";

Vue.use(VueRouter);

const contents = [
  {
    path: "/home",
    name: "home",
    component: () => import("@/views/HomeView.vue"),
  },
  {
    path: "/about",
    name: "about",
    component: () => import("@/views/AboutView.vue"),
  },
  {
    path: "/mine1",
    name: "mine1",
    component: () => import("@/views/Mine1View.vue"),
  },
  {
    path: "/mine2",
    name: "mine2",
    component: () => import("@/views/Mine2View.vue"),
  },
  {
    path: "/mine3",
    name: "mine3",
    component: () => import("@/views/Mine3View.vue"),
  },
  {
    path: "/father",
    name: "father",
    component: () => import("@/views/FatherView.vue"),
  },
  {
    path: "/promise",
    name: "promise",
    component: () => import("@/views/PromiseView.vue"),
  },
  {
    path: "/echarts",
    name: "echarts",
    component: () => import("@/views/EchartsView.vue"),
  },
  {
    path: "/shopSubmit",
    name: "shopSubmit",
    component: () => import("@/views/ShoppingSubmitter.vue"),
  },
  {
    path: "/shopAudit",
    name: "shopAudit",
    component: () => import("@/views/ShoppingAuditor.vue"),
  },
  {
    path: "/cssFirst",
    name: "cssFirst",
    component: () => import("@/views/CssFirst.vue"),
  },
  {
    path: "/cssSecond",
    name: "cssSecond",
    component: () => import("@/views/CssSecond.vue"),
  },
];

const routes = [
  { path: "/", redirect: "/home" },

  {
    path: "/logon",
    name: "logon",
    component: () => import("@/viewx/LogonPage.vue"),
  },
  {
    path: "/content",
    name: "content",
    component: () => import("@/viewx/ContentPage.vue"),
    children: contents,
  },
];
const router = new VueRouter({
  routes,
});

/* const whiteList = ["/logon", "/ddd"];
router.beforeEach((to, from, next) => {
  // console.log("========> from :");
  // console.log(from);
  // console.log("========> to :");
  // console.log(to);
  // console.log(next);
  if (whiteList.includes(to.path)) {
    console.log(to);
    next();
  } else {
    if (store.state.userinfo) {
      console.log(to);
      next();
    } else {
      next({
        path: "/logon",
        query: {
          notice: "请先登录",
        },
      });
      // router.push("/logon")
    }
  }
});*/

export default router;
